Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

254
Visualizações
Problems using "require" with two script-tags

I have a function loadDays() that should be called when my body section is loaded:

<body onload="loadDays()">

My loadDays() function looks like this:

<script>
    function loadDays() {  
        // Code
    }
</script>
      

Inside of loadDays() I need to access an excel-file.

So I added src="https://requirejs.org/docs/release/2.3.5/minified/require.js" to the <script> tag.

But then I recieved the following error:

Uncaught ReferenceError: loadDays is not defined at onload


Then someone gave me the hint to use two different <script> tags:

<script src="https://requirejs.org/docs/release/2.3.5/minified/require.js">
    const Excel = require('exceljs');
</script>

<script>
    function loadDays() {       
        // Code
    }
</script>

But now I have the problem that it says:

Uncaught ReferenceError: Excel is not defined at loadDays

How can I solve this issue?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

As an alternative, in your script you could use a 'DOMready' event :

https://developer.mozilla.org/en-US/docs/Web/API/Window/DOMContentLoaded_event

window.addEventListener('DOMContentLoaded', (event) => {
    console.log('DOM fully loaded and parsed');
});

Everything inside this event will be executed once the full DOM is loaded

If you import well your script, that should do the trick

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda